package fgame.controller.state
{
	import fgame.GameState;
	import fgame.controller.Controller;
	import fgame.graphic.Graphic;
	import fgame.unit.Actor3D;
	
	import flare.primitives.Box;
	
	import flash.geom.Point;
	import flash.geom.Vector3D;
	
	/**
	 * 点击地图
	 */
	public class MapClickState extends State
	{
		public function MapClickState(controller:Controller=null)
		{
			super(controller);
			p1=new Point();
			p2=new Point();
			box=new Box("target",30,30,30);
			
		}
		
		override public function begin():void
		{
			var actor:Actor3D=controller.target as Actor3D;
			var n:String=actor.name;
			var graphic:Graphic=actor.graphic as Graphic;
			p1.x=graphic.x;p1.y=graphic.z;
			p2.x=info.x;p2.y=info.z;
			
			var s1:Number=p2.subtract(p1).length;
			var v1:Number=actor.data.speed/1000;
			var arg:Object={"v":v1,"s":s1,"p":info};
			
			box.setPosition(info.x,info.y,info.z);

			box.parent=GameState.inst.sceneManager.scene;
			MsgHelper.sendActMsg(n,4,arg,11);
			
		}
		
		public var info:Vector3D,p1:Point,p2:Point;
		
		private var box:Box;
	}
}